package com.rocky.pubimport.common;


import lombok.Data;

/**
 * 导入数据响应实体类
 * @author rocky
 * @date 2022/4/13 17:00
 */
@Data
public class ResponseImportResult {

    /** 标识码 */
    private String code;

    /** 响应信息 */
    private String message;

    /** 成本标记 */
    private boolean success;

    private ImportResult data;

    public ResponseImportResult() {
        this.code = "200";
        this.message = "success";
        this.success = true;
    }

    public ResponseImportResult(ImportResult data) {
        this();
        this.data = data;
    }

    public ResponseImportResult(String code, String message, boolean success) {
        this.code = code;
        this.message = message;
        this.success = success;
    }

    public ResponseImportResult(String code, String message, boolean success, ImportResult data) {
        this.code = code;
        this.message = message;
        this.success = success;
        this.data = data;
    }

    public static ResponseImportResult ok() {
        return new  ResponseImportResult();
    }

    public static ResponseImportResult ok(String message) {
        return new  ResponseImportResult("200", message, true);
    }

    public static ResponseImportResult ok(ImportResult importResult) {
        return new  ResponseImportResult(importResult);
    }

    public static ResponseImportResult error() {
        return new ResponseImportResult("-200", "error", false);
    }

    public static ResponseImportResult error(String message) {
        return new ResponseImportResult("-200", message, false);
    }

    public static ResponseImportResult error(ImportResult importResult) {
        return new  ResponseImportResult("-200", "error", false, importResult);
    }

    @Data
    public static class ImportResult {
        /** 成功导入数量 */
        private Integer successImportNum;
        /** 错误导入数量 */
        private Integer errorImportNum;
        /** 成功导入Excel */
        private String successImportFile;
        /** 错误导入excel */
        private String errorImportFile;
        /** 导入状态 */
        private String importStatus;

    }


}
